package xiaopiya.robot.handler.rss.tool;

import java.util.Timer;
import java.util.TimerTask;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author Ray (ayufox@gmail.com)
 * 
 */
public class RssBookingJob extends TimerTask
{
	private final static Log LOG = LogFactory.getLog(RssBookingJob.class);

	private IRssBookingService rssBookingService;

	public void setRssBookingService(IRssBookingService rssBookingService)
	{
		this.rssBookingService = rssBookingService;
	}

	/* (non-Javadoc)
	 * @see java.util.TimerTask#run()
	 */
	public synchronized void run()
	{
		try
		{
			if (LOG.isInfoEnabled())
			{
				LOG.info("publish check");
			}
			this.rssBookingService.publish();
		} catch (Throwable t)
		{
			LOG.error("error when publish rss", t);
		}
	}

	private long period = 2 * 60 * 1000;
	private Timer timer;
	
	
	public void init()
	{
		this.timer = new Timer();
		this.timer.schedule(this, 10 * 1000, this.period);
	}
	
	public void destroy()
	{
		
	}
}